package org.blogspot.t0yv0.marcalog.controller

import com.google.appengine.api.labs.taskqueue._

object Tasks {

  val queue = QueueFactory.getDefaultQueue();

  def schedule(t: Task) {
    val cN = t.getClass.getName;
    var tO = TaskOptions.Builder.url("/admin/task/" + cN);
    for ((k, v) <- t.parameters) {
      tO = tO.param(k, v);
    }
    t.payload match {
      case None    => {};
      case Some(p) => tO = tO.payload(p);
    }
    queue.add(tO);
  }

}
